package com.incrediblesoft.redjey.font4me;

import javax.swing.filechooser.FileFilter;
import java.io.File;

public class FontFilter extends FileFilter
{
    public static final int TTF_FILTER = 0;
    public static final int PNG_FILTER = 1;
    public static final int FNT_FILTER = 2;
    final int filterType;

    public FontFilter(int filterType)
    {
        this.filterType = filterType;
    }

    //Accept all directories and all gif, jpg, tiff, or png files.        j
    public boolean accept(File f)
    {
        if (f.isDirectory())
            return true;

        String extension = Font4ME.getExtension(f);
        if (extension != null)
        {
            if (filterType == TTF_FILTER && extension.equals("ttf"))
                return true;
            else if (filterType == PNG_FILTER && extension.equals("png"))
                return true;
            else if (filterType == FNT_FILTER && extension.equals("fnt"))
                return true;
        }

        return false;
    }

    //The description of this filter
    public String getDescription() {
        if (filterType == TTF_FILTER) return "True-type fonts";
        else if (filterType == FNT_FILTER) return "RedJey font";
        else return "PNG image";
    }

    public int getType()
    {
        return filterType;
    }
}

